HA$PBExportHeader$u_cst_manto_main.sru
forward
global type u_cst_manto_main from u_cst_tabpage
end type
type st_msj from statictext within u_cst_manto_main
end type
type st_det2 from statictext within u_cst_manto_main
end type
type st_det1 from statictext within u_cst_manto_main
end type
type st_titulo from statictext within u_cst_manto_main
end type
type dw_2 from datawindow within u_cst_manto_main
end type
type uo_toolbarstrip from u_cst_toolbarstrip within u_cst_manto_main
end type
type dw_1 from datawindow within u_cst_manto_main
end type
type uo_1 from u_cst_statictext within u_cst_manto_main
end type
end forward

global type u_cst_manto_main from u_cst_tabpage
integer width = 3090
integer height = 2140
event ue_mostrar ( powerobject ap_object,  boolean ab_tab,  integer ai_sw )
event type integer ue_grabar ( )
event ue_copy_fila ( datawindow ad_dw,  integer ai_row,  integer ai_sw )
event ue_grabar_previo ( )
event ue_nuevo ( )
event ue_ver_object ( boolean ab_ver )
event ue_editar ( string as_codigo )
event type long ue_getdwmodified ( )
event ue_ver_default ( )
event ue_settabtext ( string as_titulo )
event ue_setdwc ( )
event ue_setrow ( integer ai_row )
event type integer ue_validar ( )
event type integer ue_validardw ( )
st_msj st_msj
st_det2 st_det2
st_det1 st_det1
st_titulo st_titulo
dw_2 dw_2
uo_toolbarstrip uo_toolbarstrip
dw_1 dw_1
uo_1 uo_1
end type
global u_cst_manto_main u_cst_manto_main

type variables
s_parm istr_parm
boolean dw_has_focus
string is_error  ,is_button,is_tabla ,is_idcodigo,is_entidad,is_user,is_contrase$$HEX1$$f100$$ENDHEX$$a
long il_id ,il_error=0
integer ii_currentrow , ii_row,ii_sw,ii_idcodigo
datastore ids_datastore
Window iw_parent
//u_cst_tabcontrol iuo_parent 
datawindowchild dwc
u_cst_powerdock uo_powerdock
userobject iuo_tab
u_cst_grillamain iuo_grillamain
userobject iuo_tabmantomain
end variables

forward prototypes
public function integer of_getwindow ()
public function integer of_getcolor (string as_color)
public subroutine of_retrieve (long al_codigo)
public subroutine of_retrieve (integer ai_codigo)
public subroutine of_retrieve (string as_codigo)
public function long of_getcodigo ()
public function string of_getcodigo (string as_tabla)
end prototypes

event ue_mostrar(powerobject ap_object, boolean ab_tab, integer ai_sw);string ls_dw,ls_button,ls_entidad
long ll_codigo,ll_Rows

istr_parm        = ap_object
ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
uo_powerdock = istr_parm.auo_powerdock 
ls_button         = istr_parm.as_button
ls_dw              = ids_datastore.object.tDw1[1]
is_tabla           = ids_datastore.object.tTabla[1]
iuo_tab            = istr_parm.auo_userobject 
iuo_grillamain  = istr_parm.auo_grillamain
iuo_tabmantomain = istr_parm.auo_tabmantomain
is_idcodigo			=  istr_parm.as_parm[1] //id tabla
if ls_dw = '' or isnull(ls_dw) then return

is_button = ls_button
//if  ab_tab  then
dw_1.dataobject=ls_dw
dw_2.dataobject=ls_dw
dw_1.settransobject(sqlca)
dw_2.settransobject(sqlca)
//end if

//choose case upper(is_button)
//	case 'NUEVO'
//		dw_1.accepttext( ) //= -1  then return
//		ll_Rows = dw_1.ModifiedCount()
//		IF ll_Rows > 0 then
//			choose case f_msg('$$HEX1$$bf00$$ENDHEX$$Estas editando una empresa. $$HEX1$$bf00$$ENDHEX$$Quieres guardar los cambios?',5) 
//				case 3 //es cuando cancelas
//					return
//				case 2 //aqui es cuando no grabas y sales
//					dw_1.reset()
//					dw_1.insertrow( 0)
//					iuo_grillamain.event dynamic ue_dw_enabled(true)//activa para no poder modificar 
//				case 1 //aqui grabas y sales
//					 event ue_grabar( )
//					 uo_toolbarstrip.of_setenabled( 'Grabar', true)		
//					 uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//					 iuo_grillamain.event dynamic ue_dw_enabled(false,ll_Rows)
//					 //iuo_tabmantomain.event dynamic ue_enabled_object(true,0)
//					return
//			end choose
//		end if
//		uo_powerdock.of_setdocumenttext( iuo_tab ,'Nuevo / '+ is_tabla)
//		dw_1.reset()
//		dw_1.insertrow( 0)
//		dw_1.enabled= true
//		dw_1.visible = true
//		dw_2.visible = false
//		uo_toolbarstrip.visible = true
//		uo_toolbarstrip.of_setvisible( 'Grabar', true)
//		uo_toolbarstrip.of_setvisible( 'Cancelar', true)
//		uo_toolbarstrip.of_setvisible( 'Editar', false)
//		uo_toolbarstrip.of_setvisible( 'Borrar', false)
//		uo_toolbarstrip.of_setenabled( 'Grabar', true)		
//		uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//		iuo_grillamain.event dynamic ue_dw_enabled(true,ll_Rows)
//	//	iuo_tabmantomain.event dynamic ue_enabled_object(false,0)
//	CASE 'EDITAR'
//		dw_1.accepttext( ) //= -1  then return
////		ll_Rows = dw_1.ModifiedCount()
////		IF ll_Rows > 0  then
////			if f_msj('$$HEX1$$bf00$$ENDHEX$$Desa guardar los cambios que hizo al usuario?',2) = 2 then return
////		end if
//
//		uo_powerdock.of_setdocumenttext( iuo_tab ,'Editar / '+ is_tabla)
//		dw_1.retrieve(is_idcodigo) ;				commit;
//		dw_1.enabled= true
//		uo_toolbarstrip.of_setenabled( 'Grabar', true)		
//		uo_toolbarstrip.of_setenabled( 'Cancelar', TRUE)
////	CASE 'CONSULTAR'
////		dw_1.accepttext( )// = -1  then return
////		ll_Rows = dw_1.ModifiedCount()
////		IF ll_Rows > 0  then
////			if f_msj('$$HEX1$$bf00$$ENDHEX$$Desa guardar los cambios que hizo al usuario?',2) = 2 then return
////		end if
////		uo_powerdock.of_setdocumenttext( iuo_tab ,'Consultar / '+ is_tabla)
////		dw_1.retrieve(is_idcodigo) ; 	commit;
////		dw_1.enabled= false
////		uo_toolbarstrip.of_setenabled( 'Grabar', false)
////		uo_toolbarstrip.of_setenabled( 'Cancelar', false)
//END CHOOSE

end event

event type integer ue_grabar();integer li_return=1,li_fila
string ls_empresa


if dw_1.accepttext( ) =  - 1  then return 0
If f_findrequired(dw_1) = -1 Then Return 0

EVENT UE_GRABAR_PREVIO()

if event ue_validarDW() <> 0  then return 0

if dw_1.update(true,false) = 1 then
	dw_2.reset(); dw_2.clear()
	dw_1.RowsCopy(dw_1.GetRow(),dw_1.GetRow(), primary!, dw_2, 1, Primary!)
	dw_1.resetupdate();	commit;
	if is_tabla = 'MUSER' THEN
		sqlca.USP_SetPassword(is_user,'C1trase$$HEX1$$f100$$ENDHEX$$a',is_contrase$$HEX1$$f100$$ENDHEX$$a)
		commit;
	END IF
	iuo_grillamain.event dynamic ue_refrescar_row(dw_2,ii_row,is_button)
	//f_msj('Guardado satisfactoriamente',4)
	
	iuo_grillamain.event ue_activa_opc( false)
	event ue_ver_object(false)
	st_msj.visible = true ; 	st_msj.text = 'Registro Grabado satisfactoriamente...'
	event ue_settabtext( 'Consultar')
	return 1

else
	//dw_1.resetupdate()
	rollback ;
	f_msj('Error',1)
	return 0
end if
return 0

end event

event ue_copy_fila(datawindow ad_dw, integer ai_row, integer ai_sw);long ll_rows
dw_1.reset()
dw_2.reset(); dw_2.clear()
event ue_settabtext( 'Consultar')

ii_sw =ai_sw
ii_row  = ai_row
dw_2.object.data = ad_dw.object.data

event ue_setdwc()

//dw_2.visible=true

end event

event ue_grabar_previo();string ls_correlativo,ls_pass,ls_getpass
long ll_movimiento
integer li_existe
choose case upper(is_button)
	case 'NUEVO'
		choose case upper(is_tabla)
				case  ''
				case 'MITEMPRECIO'	
					dw_1.object.idusercreator[1]= gs_iduser
				case 'MITEM','MANALISIS','MPLNC'
					dw_1.object.iduser[1]= gs_iduser
					
				case 'MUSER'
					
					is_user	= dw_1.object.iduser[1]
					is_contrase$$HEX1$$f100$$ENDHEX$$a = dw_1.object.tpassword[1]
					
					
					
//					ls_pass = dw_1.object.tpassword[1]
//					ls_getpass = space(50)
//					sqlca.USP_SetPassword(ls_pass,'C1trase$$HEX1$$f100$$ENDHEX$$a',ls_getpass)
//					dw_1.object.tpassword[1] = ls_getpass
					
				case 'MMENU','MUNID','MTOOLBAR','MGMENU','MBUTTON','MDIARIO','MSUBDIARIO'
				dw_1.object.data[1,1] = of_getcodigo(is_tabla)
			CASE ELSE
				dw_1.object.data[1,1] = of_getcodigo()
		END CHOOSE

		
	case 'EDITAR'
		choose case upper(is_tabla)
			case 'MITEM','MITEMPRECIO','MANALISIS','MPLNC'
				dw_1.object.idUserModified[1]= gs_iduser
				dw_1.object.fModified[1]=today()
			case 'MUSER','MANALISIS'
					is_user	= dw_1.object.iduser[1]
					is_contrase$$HEX1$$f100$$ENDHEX$$a = dw_1.object.tpassword[1]

		END CHOOSE	
end choose


end event

event ue_nuevo();is_button = 'Nuevo'
dw_1.reset()
dw_1.insertrow(0)

choose case upper(is_tabla)
//	case 'MITEMPRECIO'
//		dw_1.object.data[1,1] = of_getcodigo()
		
	case 'MUSER'
		dw_1.settaborder( 'iduser',10)
		dw_1.setcolumn( 'iduser');dw_1.setfocus()
	CASE ''
//		F_MSG('No existe configurado el nombre de la tabla en el catalogo de menus',1)
//		return
	case 'MMENU','MUNID','MTOOLBAR','MGMENU','MBUTTON','MSUBDIARIO','MDIARIO'
		dw_1.object.data[1,1] = of_getcodigo(is_tabla)
	CASE ELSE
		dw_1.object.data[1,1] = of_getcodigo()
END CHOOSE


//dw_1.setcolumn(2) ; dw_1.setfocus( )
//IF LEN(IS_TABLA) > 0  THEN 


end event

event ue_ver_object(boolean ab_ver);boolean lb_sw
if ab_ver = true then lb_sw = false
if ab_ver = false then lb_sw = true

dw_1.enabled= ab_ver
dw_2.enabled = ab_ver

uo_toolbarstrip.visible = true
uo_toolbarstrip.of_setvisible( 'Grabar', ab_ver)
uo_toolbarstrip.of_setvisible( 'Cancelar', ab_ver)
uo_toolbarstrip.of_setvisible( 'Editar', lb_sw)
uo_toolbarstrip.of_setvisible( 'Borrar', lb_sw)
uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)		
uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)

dw_1.visible = ab_ver
dw_2.visible = lb_sw
//iuo_grillamain.event dynamic ue_dw_enabled(true,ll_Rows)
end event

event ue_editar(string as_codigo);dw_1.retrieve(as_codigo) ;	
commit;
end event

event type long ue_getdwmodified();dw_1.accepttext( ) //= -1  then return
return dw_1.ModifiedCount()
end event

event ue_ver_default();boolean lb_sw
//if ab_ver = true then lb_sw = false
//if ab_ver = false then lb_sw = true

dw_1.enabled= false

dw_1.visible = false
dw_2.visible = false
uo_1.visible = true
uo_toolbarstrip.visible = false
st_titulo.visible = true
st_det1.visible = true
uo_toolbarstrip.of_setvisible( 'Grabar', false)
uo_toolbarstrip.of_setvisible( 'Cancelar', false)
uo_toolbarstrip.of_setvisible( 'Editar', false)
uo_toolbarstrip.of_setvisible( 'Borrar', false)
uo_toolbarstrip.of_setenabled( 'Grabar', false)		
uo_toolbarstrip.of_setenabled( 'Cancelar', false)
end event

event ue_settabtext(string as_titulo);


uo_powerdock.of_setdocumenttext( uo_powerdock.of_getactiveobject( ) ,as_titulo)


end event

event ue_setdwc();

choose case UPPER(is_tabla)
	CASE 'MCONDUCTOR','MUNIDADTRANSPORTE'
		dw_2.GetChild("idemptransporte", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )	
	CASE 'MCLIENTE'
		dw_2.GetChild("idzona", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )	
//		CASE 'MCORRELATIVO'
//		dw_2.GetChild("iddocu", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )		
	CASE 'MAREA'
		dw_2.GetChild("idgere", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )	
	CASE 'MBANCOCUENTA'
		dw_2.GetChild("idbanco", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )	
	CASE 'MSOLICITUD'
		
		dw_2.GetChild("idcatesoli", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )	
	case 'MUSERMAQ'
			dw_2.GetChild("idmaq", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )		
	case 'MUSER'
			dw_2.GetChild("idperfil", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
			dw_2.GetChild("idarea", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
//	case 'MPROV'
//			dw_2.GetChild("idmodulo", dwc);dwc.reset();	dwc.settransobject( sqlca);	dwc.retrieve( )
	case 'MGMENU'
			dw_2.GetChild("idmodulo", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
	case 'MMENU'	
			dw_2.GetChild("idtoolbar", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
	case 'MALMACEN'
			dw_2.GetChild("idcentro", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
	case 'MITEMPRECIO'
			dw_2.GetChild("iditem", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
			dw_2.GetChild("idtprecio", dwc);dwc.reset();			dwc.settransobject( sqlca);			dwc.retrieve( )
	case 'MGUNID' 
			dw_2.GetChild("idunid", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
			dw_2.GetChild("idunidBase", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
	case 'MITEM'
			dw_2.GetChild("idunid", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
			dw_2.GetChild("idtipoitem", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
			
			
			dw_2.GetChild("idgrupo", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
			
			
			dw_2.GetChild("idfami", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
			
			dw_2.GetChild("idsubfami", dwc);dwc.reset()
			dwc.settransobject( sqlca)
			dwc.retrieve( )
	End Choose
commit;
end event

event ue_setrow(integer ai_row);ii_row=ai_row
end event

event type integer ue_validar();return 0 
end event

event type integer ue_validardw();integer li_existe
string ls_pass
choose case is_tabla
	case  'MUSER'
		if UPPER(is_button)  = 'NUEVO' then
			select count(*) into :li_existe from muser where iduser = :is_user ;
			if li_existe > 0 then
				f_msj('Usuario ya existe',4); return -1
			end if
		else
			ls_pass = trim(dw_1.object.tpassword [1])
			if isnull(ls_pass)  or ls_pass='' or len(ls_pass)=0 then
				f_msj('Ingreso la contrase$$HEX1$$f100$$ENDHEX$$a',4);		return - 1
			end if
		end if

	
End choose



return 0 
end event

public function integer of_getwindow (); PowerObject	lpo_parent
Window lw_window

// loop thru parents until a window is found
lpo_parent = GetParent()
Do While lpo_parent.TypeOf() <> Window! and IsValid(lpo_parent)
	lpo_parent = lpo_parent.GetParent()
Loop

// set return to the window or null if not found
If IsValid (lpo_parent) Then
	lw_window = lpo_parent
Else
	SetNull(lw_window)
End If

iw_parent = lw_window

RETURN 1
end function

public function integer of_getcolor (string as_color);Long ll_color
//
//CHOOSE CASE Upper(as_color)
//	CASE "BACKGROUND2"
//		CHOOSE CASE iuo_parent.il_CurrentTheme
//			CASE iuo_parent.BLUE
//				ll_color = RGB(129,169,226)
//			CASE iuo_parent.SILVER
//				ll_color = RGB(153,151,181)
//			CASE iuo_parent.OLIVE
//				ll_color = RGB(183,198,145)
//			CASE iuo_parent.CLASSIC
//				ll_color = RGB(213,210,202)
//		END CHOOSE
//END CHOOSE
//
RETURN ll_color
end function

public subroutine of_retrieve (long al_codigo);dw_1.retrieve(al_codigo);commit;
end subroutine

public subroutine of_retrieve (integer ai_codigo);dw_1.retrieve(ai_codigo); commit;
end subroutine

public subroutine of_retrieve (string as_codigo);string ls_getpass
dw_1.retrieve(as_codigo);commit;

if is_tabla ='MUSER' then
	ls_getpass = space(50)
	sqlca.USP_GetPassword(as_codigo,'C1trase$$HEX1$$f100$$ENDHEX$$a',ls_getpass)
	dw_1.object.tpassword [1] = ls_getpass
	dw_1.settaborder( 'iduser',0)
end if

end subroutine

public function long of_getcodigo ();long ll_movimiento
ll_movimiento=0
sqlca.Usp_GetIdTablaINT(is_tabla,ll_movimiento)
dw_1.object.data[1,1]=ll_movimiento

return ll_movimiento




end function

public function string of_getcodigo (string as_tabla);string ls_codigo
//SQLCA.Usp_GetIdTabla(as_tabla,'')

ls_codigo  = Space(50)
sqlca.usp_getidtabla(as_tabla, ls_codigo)
return ls_codigo

end function

on u_cst_manto_main.create
int iCurrent
call super::create
this.st_msj=create st_msj
this.st_det2=create st_det2
this.st_det1=create st_det1
this.st_titulo=create st_titulo
this.dw_2=create dw_2
this.uo_toolbarstrip=create uo_toolbarstrip
this.dw_1=create dw_1
this.uo_1=create uo_1
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.st_msj
this.Control[iCurrent+2]=this.st_det2
this.Control[iCurrent+3]=this.st_det1
this.Control[iCurrent+4]=this.st_titulo
this.Control[iCurrent+5]=this.dw_2
this.Control[iCurrent+6]=this.uo_toolbarstrip
this.Control[iCurrent+7]=this.dw_1
this.Control[iCurrent+8]=this.uo_1
end on

on u_cst_manto_main.destroy
call super::destroy
destroy(this.st_msj)
destroy(this.st_det2)
destroy(this.st_det1)
destroy(this.st_titulo)
destroy(this.dw_2)
destroy(this.uo_toolbarstrip)
destroy(this.dw_1)
destroy(this.uo_1)
end on

event constructor;call super::constructor;string ls_dw3,ls_dw2,ls_opc,ls_dw,ls_user
long ll_codigo

istr_parm = message.powerobjectparm 

uo_toolbarstrip.visible = false
dw_1.visible = false
of_getwindow()

ids_datastore   = istr_parm.ads_menu //aqui recupera el datastore
uo_powerdock = istr_parm.auo_powerdock 
is_button         = istr_parm.as_button
ls_dw              = ids_datastore.object.tDw1[1]
is_tabla           = ids_datastore.object.tTabla[1]
IF ISNULL(is_tabla) THEN is_tabla =''

is_entidad = ids_datastore.object.tEntidad[1]
iuo_tab            = istr_parm.auo_userobject 
iuo_grillamain  = istr_parm.auo_grillamain
iuo_tabmantomain = istr_parm.auo_userobject
//is_idcodigo			=  istr_parm.as_parm[1] //id tabla
if ls_dw = '' or isnull(ls_dw) then return

dw_1.dataobject=ls_dw
dw_2.dataobject=ls_dw
dw_1.settransobject(sqlca)
dw_2.settransobject(sqlca)
dw_1.reset()
st_titulo.text = ids_datastore.object.tTitulo[1]
st_det1.text = ids_datastore.object.tObse1[1]
st_det2.text = ids_datastore.object.tObse2[1]
il_error =0
//uo_1.of_BackColor2(of_GetColor("BACKGROUND2"))
uo_1.of_BackColor2(RGB(129,169,226))

//event post ue_settabtext ('')
//EVENT ue_mostrar (istr_parm,true,0)



end event

event resize;call super::resize;uo_toolbarstrip.Width =(this.width - 12) 
DW_2.Resize(Width, Height  )
DW_1.Resize(Width, Height  )
uo_1.Resize(newWidth, newHeight)
end event

event ue_postconstructor;call super::ue_postconstructor;//choose case upper(is_button)
//	case 'NUEVO'
//		  uo_toolbarstrip.of_setenabled( 'Grabar', true)	
//		  uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//		  dw_1.setcolumn( 4)
//		  dw_1.setfocus( )
//		 
//	case 'EDITAR'
//		 uo_toolbarstrip.of_setenabled( 'Grabar', true)	
//		 uo_toolbarstrip.of_setenabled( 'Cancelar', true)
//		 dw_1.setcolumn( 4)
//		 dw_1.setfocus( )
// case 'CONSULTAR'
//		 uo_toolbarstrip.of_setenabled( 'Grabar', FALSE)		
//		uo_toolbarstrip.of_setenabled( 'Cancelar', false)
//End choose 
//
end event

type st_msj from statictext within u_cst_manto_main
boolean visible = false
integer x = 512
integer y = 1988
integer width = 1824
integer height = 100
integer textsize = -12
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 15780518
alignment alignment = center!
boolean border = true
boolean focusrectangle = false
end type

type st_det2 from statictext within u_cst_manto_main
integer x = 32
integer y = 244
integer width = 1824
integer height = 76
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 16777215
boolean focusrectangle = false
end type

type st_det1 from statictext within u_cst_manto_main
integer x = 32
integer y = 144
integer width = 1824
integer height = 76
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 33554432
long backcolor = 16777215
string text = "* Selecciona un contacto para ver o editar sus datos"
boolean focusrectangle = false
end type

type st_titulo from statictext within u_cst_manto_main
integer x = 37
integer y = 24
integer width = 1819
integer height = 80
integer textsize = -12
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long textcolor = 8388608
long backcolor = 16777215
string text = "Empresas:"
boolean focusrectangle = false
end type

type dw_2 from datawindow within u_cst_manto_main
boolean visible = false
integer y = 104
integer width = 3086
integer height = 1996
integer taborder = 20
string title = "none"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

type uo_toolbarstrip from u_cst_toolbarstrip within u_cst_manto_main
boolean visible = false
integer width = 3067
integer taborder = 20
end type

on uo_toolbarstrip.destroy
call u_cst_toolbarstrip::destroy
end on

event ue_buttonclicked;call super::ue_buttonclicked;string ls_columna,ls_tipo,ls_codigo
integer li_codigo
long ll_codigo
choose case upper(as_button)
	
	case 'EDITAR'
		
		   is_button  =	as_button
		   iuo_tabmantomain.EVENT DYNAMIC ue_setbutton(as_button)
		   iuo_tabmantomain.EVENT DYNAMIC	ue_set_ib_sw(true)
//		   is_idcodigo =dw_2.object.data[1,1]
		   iuo_grillamain.event ue_activa_opc( true)
		   event ue_settabtext ('Editar '+ is_entidad)
		   event ue_ver_object(true)
		   ls_columna = dw_1.describe('#'+string(1)+'.name')
		   ls_tipo = dw_1.describe(ls_columna+'.coltype')	
			if left(ls_tipo,4)='char' then
				 ls_codigo =dw_2.object.data[1,1]
				 of_retrieve( ls_codigo)	
			elseif ls_tipo='int' then
				 li_codigo =dw_2.object.data[1,1]
				 of_retrieve( li_codigo)	
			else
				ll_codigo =dw_2.object.data[1,1]
				 of_retrieve( ll_codigo)	
			end if		
//					
//			elseif ls_tipo='int' or ls_tipo='long' or ls_tipo='number' or ls_tipo='real' then
			
//				end if		
//					
//			elseif left(ls_tipo,7)='decimal' then

//				end if		
//					
//			elseif ls_tipo='date' then

//				end if		
//					
//			elseif ls_tipo='datetime' then

//			end if
	case 'GRABAR'
		event  ue_grabar( )
	case 'CANCELAR'
		
		if	event ue_getdwmodified( ) > 0 then
			if f_msg('Cambio realizados ... $$HEX1$$bf00$$ENDHEX$$Esta seguro que desea cancelar ?',7) = 2 then return
	
		end if
		IF UPPER(is_button) = 'EDITAR' Then
			event ue_ver_object(false)
		elseif	UPPER(is_button) = 'NUEVO'  THEN
			event ue_ver_default()
			 event ue_settabtext ('Principal')
			//uo_powerdock.of_setdocumenttext( iuo_tab ,'Consultar / '+is_entidad)
			//dw_1.enabled= false
		end if	
		dw_1.reset()
		iuo_grillamain.event dynamic ue_activa_opc(false)  
		iuo_grillamain.event dynamic ue_bloquear_refrescar(false) 
		//	iuo_tab.event dynamic ue_enabled_object(true)
		//	case 'SALIR'
		//		uo_powerdock.of_closedocument(uo_powerdock.of_getactiveobject( ))
END CHOOSE
end event

event constructor;call super::constructor;this.of_AddItem('Grabar', 'Save!')
this.of_AddItem('Cancelar', 'Undo!')
this.of_AddItem('Editar', '..\IMG\ICO\edit.ico')
//this.of_AddItem('Borrar', '..\IMG\ICO\Delete.ico')

//opciones en estado invisible
this.of_setvisible( 'Grabar', false)
this.of_setvisible( 'Cancelar', false)
//esto es para mostar los textos
this.of_DisplayText(true)


end event

type dw_1 from datawindow within u_cst_manto_main
event ue_enter pbm_dwnprocessenter
event ue_setcolor ( long al_color )
boolean visible = false
integer y = 104
integer width = 3072
integer height = 2000
integer taborder = 10
string title = "none"
string dataobject = "d_mmenu_free"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event ue_enter;Send( Handle( this ), 256, 9, Long( 0, 0 ) ) // Send message for processing TAB key 
return 1 
end event

event ue_setcolor(long al_color);integer li_columna,li_index
string  ls_columna,ls_Required,ls_style

li_columna = integer(this.Object.DataWindow.Column.Count)

for li_index=1 to li_columna
	
	  ls_Columna="#" + string(li_index) + ".name"
	 //Nombre de la Columna
	 Ls_Columna=This.Describe(Ls_Columna)
	 //Estilo de Edicion
	 ls_Style=Ls_Columna + ".edit.style"
	 Ls_Style=lower(This.Describe(Ls_Style))
	 
	 CHOOSE CASE Ls_Style
		CASE 'dddw'
			Ls_Required=lower(This.Describe(Ls_Columna + ".dddw.Required"))
		CASE 'ddlb'
			Ls_Required=lower(This.Describe(Ls_Columna + ".ddlb.Required")			)
		CASE 'edit'
			Ls_Required=lower(This.Describe(Ls_Columna + ".edit.Required"))
		CASE 'editmask'
			Ls_Required=lower(This.Describe(Ls_Columna + ".editmask.Required"))
		CASE ELSE
			Continue
	 END CHOOSE
	 
	 If Ls_Required='yes' Then
		Ls_Columna=Ls_Columna + '.Background.Color=' + string(al_color)
		This.Modify(Ls_Columna)
	 End If
	 
next
end event

event itemchanged;this.accepttext( )
Choose Case dwo.name
	case 'nprecioventa'
		if dw_1.object.nexoigv[1] = 1 then 
			dw_1.object.nimpuesto1[1] = 0
			dw_1.object.nprecioneto[1]=double (data)
		else
			dw_1.object.nprecioneto[1]=double (data) / (1 + (dw_1.object.nporc1[1]/100))
			dw_1.object.nimpuesto1[1]=double (data)  -  dw_1.object.nprecioneto[1]
		end if
		
		
		
	case 'nprecioneto'	
		
		dw_1.object.nimpuesto1[1]=double (data)  * (dw_1.object.nporc1[1]/100)
		if dw_1.object.nexoigv[1] = 1 then  dw_1.object.nimpuesto1[1] = 0
		dw_1.object.nprecioventa[1] =  dw_1.object.nimpuesto1[1]+  double (data) 

	Case 'idmenu'
		If Trim(data) = '' Or IsNull(data) Then
			is_error = 'Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido'
			Return 1
		End If
End choose 
end event

event itemerror;

Choose Case dwo.name
	case 'idmenu'
		MessageBox('Advertencia','ingrese el menu',stopsign!)
	Case 'idprefil'
		MessageBox('Advertencia','ingrese el perfil',stopsign!)
//	      MessageBox('Advertencia',is_error,Stopsign!)
	Case 'cc_locac','cc_almac','ci_tipart'
//		MessageBox('Advertencia',is_error,stopsign!)
	Case 'cc_docum','cn_docum'
//		MessageBox('Advertencia',is_error,stopsign!)
End Choose
il_error =1
Return 1
end event

event constructor;event ue_setcolor(rgb(27,208,228))
end event

event rowfocuschanged;//dwitemstatus ldwitemstatus
//
//if currentrow < 1 then return
//
////if ib_lista or ib_tablist then return
//
//ldwitemstatus=this.getitemstatus(this.rowcount(),0,primary!)
//
//if ldwitemstatus=new! or ldwitemstatus=newmodified! then
//	this.scrolltorow(this.rowcount())
//	return
//end if
//
//if ii_currentrow=0 then ii_currentrow=currentrow
//this.selectrow(ii_currentrow,FALSE)
//this.selectrow(currentrow,TRUE)
//this.setrow(currentrow)
//ii_currentrow=currentrow
//
end event

type uo_1 from u_cst_statictext within u_cst_manto_main
integer width = 3077
integer height = 2112
integer taborder = 20
long backcolor = 16777215
boolean #vgradientfill = true
end type

on uo_1.destroy
call u_cst_statictext::destroy
end on

